﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

/// <summary>
/// Summary description for Order
/// </summary>
public class Order
{
    
    private List<OrderItem> orderitems = new List<OrderItem>();
    private List<Toppings> orderitemtoppings = new List<Toppings>();
    private int toppingNum = 0;


    private int orderitemcount = 0;

    public Order(int orderid)
    {
        OrderID = orderid;
    }

    public int CustomerID
    {
        get;
        set;
    }

    public int PaymentID
    {
        get;
        set;
    }

    public int OrderID
    {
        get;
        set;
    }

    public OrderItem getLastOrderItem()
    {
        return orderitems.ElementAt(orderitems.Count - 1);
    }

    public Toppings getLastTopping()
    {
        return orderitemtoppings.ElementAt(orderitemtoppings.Count - 1);
    }

    public void addOrderItem(int productid, int quantity, int toppingsid)
    {
        orderitems.Add(new OrderItem(productid, quantity, toppingsid));
    }

    public void addTopping(int orderid, int productid)
    {
        orderitemtoppings.Add(new Toppings(++toppingNum, orderid, productid));
    }

    public string printOrder()
    {
        string order = "";

        order += OrderID + "\n";
        order += PaymentID + "\n";
        order += CustomerID + "\n";

        if (orderitems.Count > 0)
        {
            foreach (OrderItem oi in orderitems)
            {
                order += oi.ProductID + "\n";
                order += oi.Quantity + "\n";
                order += oi.ToppingID + "\n";
            }
        }

        if (orderitemtoppings.Count > 0)
        {
            foreach (Toppings top in orderitemtoppings)
            {
                order += top.ToppingID + "\n";
                order += top.OrderID + "\n";
                order += top.ProductID + "\n";
            }
        }


        return order;
    }
    

}